package DNA序列;

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int k = in.nextInt(), res = 0;
        for (int i = 0; i < k; i++) {
            if (s[i] == 'C' || s[i] == 'G') {
                res++;
            }
        }
        int cnt = res, flag = 0;
        for (int l = 0, r = k - 1; r < s.length - 1; l++, r++) {
            if (s[l] == 'C' || s[l] == 'G') {
                cnt--;
            }
            if (s[r + 1] == 'C' || s[r + 1] == 'G') {
                cnt++;
            }
            if (res < cnt) {
                res = cnt;
                flag = l + 1;
            }
        }
        for (int i = flag; i < flag + k; i++) {
            System.out.print(s[i]);
        }
    }
}
